package lib.System.Utility;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Report 
{
	
	
	static SimpleDateFormat F = new SimpleDateFormat("yyyy-dd-MM.hh.mm.ss");
	static Date d = new Date();
	static String reporttime = F.format(d);
	static String resultsFileName = "TestReportSummary.html"; // location were you save the file

	
	static BufferedWriter reportmsg;// = new BufferedWriter(new FileWriter(resultsFileName));		
			// Date.Now.ToString("yyyy-dd-MM.hh.mm.ss");
	public static void writeTCHeading(String testcasename) throws IOException
	{
		reportmsg = new BufferedWriter(new FileWriter(resultsFileName));	

	reportmsg.write(("<h2>"));
	System.out.println(testcasename);
	reportmsg.write(testcasename);
	reportmsg.write("</h2>");
	//reportmsg.close();
	}

	public static void passMSG(String passMessage) throws IOException// throws IOException
	{
//		reporttime = F.format(d);
//		
		//BufferedWriter reportmsg;
		
			//reportmsg = new BufferedWriter(new FileWriter(resultsFileName));
		reportmsg.write("<br>");
		reportmsg.write("[" + d.getTime()  + "] " + "<font color='green'>Pass: " + passMessage + "</font>");
		reportmsg.write("/<br>");
		//reportmsg.close();
		
	}

	public static void failMSG(String failMessage) throws IOException
	{
//		reporttime = F.format(d);
//		
//		
	//	try
		//{
			//BufferedWriter reportmsg = new BufferedWriter(new FileWriter(resultsFileName));
			reportmsg.write("<br>");
			reportmsg.write("[" + d.getTime() +"] " + "<font color='red'>Fail: " + failMessage + "</font>");
			reportmsg.write("/<br>");
			//reportmsg.close();
		//}
		//catch(IOException e)
		//{
			
		//}
	}
	public static void writereport(String reporttext) throws IOException
	{

	reportmsg.write("<br>");
	reportmsg.write("[" + " " + d.getTime() + "] " + reporttext);
	reportmsg.close();
	}
	
	public static void close()
	{
		try {
			reportmsg.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
